home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-07-28 | 2.0 KB | 75 lines |
- /*
- * Title.java - Displays a Palm-like title
- * eCross is Copyright (C) 2000 Romain Guy
- * guy.romain@bigfoot.com
- * www.jext.org
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
- import waba.fx.*;
- import waba.ui.*;
-
- /**
- * A control that displays an application's title.
- * @version 1.0
- * @author Wabasoft <www.wabasoft.com> and Romain Guy <guy.romain@bigfoot.com>
- */
-
- public class Title extends Bounded
- {
- // title
- private Font font;
- private String name;
-
- /**
- * Creates a new title.
- * @param name The title label
- */
-
- public Title(String name)
- {
- this.name = name;
- this.font = new Font("Helvetica", Font.BOLD, 12);
- }
-
- public int getBoxWidth(Control c)
- {
- return (c.getFontMetrics(font).getTextWidth(name) + 8);
- }
-
- public void paint(Control c, Graphics g)
- {
- // draw line across
- g.setColor(0, 0, 0);
- int y = this.height - 1;
- g.drawLine(0, y, this.width, y);
- y--;
- g.drawLine(0, y, this.width, y);
-
- // draw title
- FontMetrics fm = c.getFontMetrics(font);
- int boxWidth = fm.getTextWidth(name) + 8;
- g.fillRect(0, 0, boxWidth, y);
- g.setColor(255, 255, 255);
- g.drawLine(0, 0, 0, 0);
- g.drawLine(boxWidth - 1, 0, boxWidth - 1, 0);
- g.setFont(font);
- g.drawText(name, 4, 2);
- }
- }
-
- // End of Title.java
-